<template>
    <div style="width: 500px">
        <Form ref="form" :label-width="150" :rules="rules" :model="form">
            <FormItem label="名称" prop="title">
                <Input type="text" v-model="form.name" />
            </FormItem>
            <FormItem label="描述" prop="key">
                <Input type="text" v-model="form.description" />
            </FormItem>
            <FormItem>
                <Button color="primary" :loading="isLoading" @click="submit">提交</Button>
                <Space :width="10" />
                <Button @click="close">取消</Button>
            </FormItem>
        </Form>
    </div>
</template>

<script>
import utils from '@js/common/utils'
export default {
    props: {
        isEdit: {
            type: Boolean,
            default: false,
        },
        dept: {
            type: Object,
            default: function(){
                return {}
            }
        },
    },
    data() {
        return {
            rules: {
                required: ['name'],
            },
            form: this.dept
        }
    },
    
    mounted() {
        
    },
    methods: {
        submit() {
            if (!this.$refs.form.valid().result) return;
            this.$emit('submit', this.form, this.isEdit)
        },
        close() {
            this.$emit('close')
        }
    }
}
</script>